package com.zhongkun.datahome.service.domain;

import com.zhongkun.datahome.service.constant.MaterialRoomRelationTypeEnum;
import com.zhongkun.datahome.service.req.cmd.room.MaterialRoomCmd;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * @Author: lifengsheng
 * @Date: 2025/4/23 10:44
 * @Desc
 */
@Data
public class MaterialRoom extends BaseEntity {
    /**
     * @see com.zhongkun.datahome.service.constant.MaterialRoomRelationTypeEnum
     */
    @ApiModelProperty("关联类型：房产/装标")
    private String relationType;

    @ApiModelProperty("关联实体id")
    private Long relationId;

    @ApiModelProperty("空间编码")
    private String roomCode;

    @ApiModelProperty("空间名称")
    private String roomName;

    public static MaterialRoom of(MaterialRoomCmd cmd) {
        MaterialRoom materialRoom = new MaterialRoom();
        materialRoom.setRelationType(cmd.getRelationType());
        materialRoom.setRelationId(cmd.getRelationId());
        materialRoom.setRoomCode(cmd.getRoomCode());
        materialRoom.setRoomName(cmd.getRoomName());
        return materialRoom;
    }

    public static MaterialRoom of(MaterialRoomRelationTypeEnum typeEnum, Long relationId, String roomCode, String roomName) {
        MaterialRoom materialRoom = new MaterialRoom();
        materialRoom.setRelationType(typeEnum.getType());
        materialRoom.setRelationId(relationId);
        materialRoom.setRoomCode(roomCode);
        materialRoom.setRoomName(roomName);
        return materialRoom;
    }
}
